<?php
require_once dirname(__DIR__)."/common.php";
//require_once __DIR__."/login_filter.php";
use app\cls\tom\Response;
use app\cls\tom\SysResource;

$material_id=$_GET['material_id'];
if(empty($material_id)){
    Response::output(-2,"素材id不能为空");
}
$key = REDIS_PREFIX."start_dub_{$material_id}";
$redis = SysResource::getRedis();
$data = $redis->get($key);
if(empty($data)){
    $db = SysResource::getDB(false);
    $db->select("a.material_id,a.pic,a.video_name,a.transcode_no_audio_video_url,a.time_length,a.lines,a.dub_number,a.share,a.transcode_video_url as video_url");
    $db->from("video as a");
    $db->where(["a.material_id"=>$material_id,"a.status"=>1,"a.type"=>2,"transcode_status"=>1]);
    $query = $db->get();
    $data = $query->one();
    $data["lines"] = json_decode($data["lines"],true);
    $redis->setex($key,5,json_encode($data));
    Response::output(0,"获取数据成功",$data);
}else{
   $data=json_decode($data);
   Response::output(0,"数据获取成功",$data);
}

